﻿<%@ Control Language="C#" Inherits="Forum.Business.ChangePassword, Forum.Business"
    AutoEventWireup="true" %>

<script type="text/javascript">
    function checkPass()
    {
        var oldPassword = document.getElementById("<%=oldPasswordTextBox.ClientID %>").value;
        oldPassword = oldPassword.replace(/(^\s*)|(\s*$)/g,"");
        if(oldPassword.length<6 || oldPassword.length>12)
        {
            alert("密码6-12位");
            document.getElementById("<%=oldPasswordTextBox.ClientID %>").focus();
            return false;
        }

        var pwd1=document.getElementById("<%=newPasswordTextBox.ClientID %>").value;
        pwd1=pwd1.replace(/(^\s*)|(\s*$)/g,"");

        if(pwd1.length<6 || pwd1.length>12){
            alert("密码6-12位");
            document.getElementById("<%=newPasswordTextBox.ClientID %>").focus();
            return false;
        }

        var pwd2=document.getElementById("<%=newPasswordConfirmTextBox.ClientID %>").value;
        pwd2=pwd2.replace(/(^\s*)|(\s*$)/g,"");
        if(pwd1!=pwd2){
            alert("密码两次输入的不一致,请重新输入!");
            document.getElementById("<%=newPasswordConfirmTextBox.ClientID %>").focus();
            return false;
        }

        var isAdministrator="<%= CurrentUser.IsAdministrator %>";
        if(isAdministrator=="True"){
            alert("因为本论坛是供大家学习用的，所以暂不允许修改系统管理员密码!");
            return false;
        }

        return true;
    }
</script>

<div class="AdminArea">
    <fieldset>
        <legend>
            <ctrl:ResourceLiteral runat="server" ResourceName="ChangePassword_Title" ResourceFile="ControlPanelResources.xml" />
        </legend>
        <div class="FormRow">
            <ctrl:ResourceLabel CssClass="LargerFieldName" runat="Server" ResourceFile="ControlPanelResources.xml"
                ResourceName="ChangePassword_OldPassword" />
            <ctrl:ValuedTextBox runat="server" TextMode="Password" MaxLength="15" CssClass="InputField SmallWidth"
                ID="oldPasswordTextBox" />
        </div>
        <div class="FormRow">
            <ctrl:ResourceLabel CssClass="LargerFieldName" runat="Server" ResourceFile="ControlPanelResources.xml"
                ResourceName="ChangePassword_NewPassword" />
            <ctrl:ValuedTextBox runat="server" TextMode="Password" MaxLength="15" CssClass="InputField SmallWidth"
                ID="newPasswordTextBox" />
        </div>
        <div class="FormRow">
            <ctrl:ResourceLabel CssClass="LargerFieldName" runat="Server" ResourceFile="ControlPanelResources.xml"
                ResourceName="ChangePassword_NewPasswordConfirm" />
            <ctrl:ValuedTextBox runat="server" TextMode="Password" MaxLength="15" CssClass="InputField SmallWidth"
                ID="newPasswordConfirmTextBox" />
        </div>
        <div class="FormRow SubmitButtonRow">
            <div class="FormRow MiddleWidth">
                <ctrl:ResourceButton OnClientClick="return checkPass();" ID="saveButton" ResourceName="Save"
                    CssClass="Button" runat="server"></ctrl:ResourceButton>
            </div>
        </div>
    </fieldset>
</div>
